import java.io.*;
import java.util.ArrayList;
import java.util.Collection;

public class League {

    private Collection<Player> players;
    private BuildPerson buildPerson;
    private Collection<Coach> coaches;

    public League() {
        this.players = new ArrayList<Player>();
        this.buildPerson = new BuildPerson();
        this.coaches = new ArrayList<Coach>();
    }

    public Collection<Player> getPlayers() {
        return players;
    }

    public static void main(String[] args) throws FileNotFoundException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        League league = new League();
        league.build();
        Listener listener = new Listener(System.out, reader, league);
        listener.listen();
    }

    public void build() throws FileNotFoundException {
        BufferedReader bufferedReader = new BufferedReader(new FileReader("league.txt"));
        Reader reader = new Reader(bufferedReader);
        reader.buildFromFile();
        players = reader.getPlayers();
        coaches = reader.getCoaches();
    }

    public Player findPlayer(String playerName) {
        for (Player player : players) {
            if (player.getName().equals(playerName)) {
                return player;
            }
        }
        return null;
    }
}
